package com.ttg.utils.connection.handler;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.nio.charset.Charset;


public class StringResponseHandler implements ResponseHandler<String> {

    public String handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
        HttpEntity entity = null;

        String var5;
        try {
            entity = ResponseHandlerHelper.handleNon2xxStatus(response);
            Charset responseCharset = ResponseHandlerHelper.getResponseCharset(entity);
            String result = EntityUtils.toString(entity, responseCharset);
            var5 = result;
        } finally {
            EntityUtils.consume(entity);
        }

        return var5;
    }
}
